//
//  UIButton+Extension.swift
//  Weibo01
//
//  Created by mac on 16/3/18.
//  Copyright © 2016年 it.cast. All rights reserved.
//

import UIKit

extension UIButton{
    
    ///构造便利函数
    convenience init(imageName: String, backGroudImage: String){
      self.init()
        //设置图片
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        //设置背景图片
        setBackgroundImage(UIImage(named: backGroudImage), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: backGroudImage + "_highlighted"), forState: UIControlState.Highlighted)
        
        //设置按钮的大小 自适应性和图片一样大
        sizeToFit()
    }
}